package com.wst.wst_server.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.wst.wst_server.entity.Person;
import com.wst.wst_server.entity.Section;
import com.wst.wst_server.service.IPersonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zyk
 * @since 2023-03-24
 */
@RestController
@RequestMapping("/person")
public class PersonController {

    @Autowired
    IPersonService service;

    @RequestMapping("/getperson")
    public ResponseResult<List<Person>> getPerson(){
        return new ResponseResult<List<Person>>(200,"ok",service.list());
    }
    @RequestMapping("/getbypage")
    public ResponseResult<IPage<Map<String ,Object>>> getbypage(@RequestParam Map<String,Object> map){

        return new ResponseResult<IPage<Map<String ,Object>>>(200,"ok",service.getbypersonandsection(map));
    }
    @RequestMapping("/getbycontion")
    public ResponseResult<IPage<Map<String ,Object>>> getbycontion(@RequestParam Map<String,Object> map){

        return new ResponseResult<IPage<Map<String ,Object>>>(200,"ok",service.getbypersoncondition(map));
    }
    @RequestMapping("/personadd")
    public ResponseResult getpersonadd(Person person){
        return new ResponseResult(200,"ok",service.save(person));
    }
    @RequestMapping("/getbypersonid")
    public ResponseResult<Person> getbyid(Integer id){
        return new ResponseResult<Person>(200,"ok",service.getById(id));
    }
    @RequestMapping("/getbypersonidupdate")
    public ResponseResult getbyidupdate(Person person){
        return new ResponseResult(200,"ok",service.saveOrUpdate(person));
    }
    @RequestMapping("/deletebyid")
    public ResponseResult deletebyid(Integer id){
        return new ResponseResult(200,"ok",service.removeById(id));
    }

    @RequestMapping("/get1")
    public ResponseResult get1(@RequestParam Map<String ,Integer> map){
        System.out.println(map);
        List<Integer> ids = new ArrayList<>(map.values());
        return new ResponseResult(200,"ok",service.get1(ids));
    }
    @RequestMapping("/get2")
    public ResponseResult get2(@RequestParam Map<String ,Integer> map){
        System.out.println(map);
        List<Integer> ids = new ArrayList<>(map.values());
        return new ResponseResult(200,"ok",service.get2(ids));
    }
    @RequestMapping("/get3")
    public ResponseResult get3(@RequestParam Map<String ,Integer> map){
        System.out.println(map);
        List<Integer> ids = new ArrayList<>(map.values());
        return new ResponseResult(200,"ok",service.get3(ids));
    }
    @RequestMapping("/get4")
    public ResponseResult get4(@RequestParam Map<String ,Integer> map){
        System.out.println(map);
        List<Integer> ids = new ArrayList<>(map.values());
        return new ResponseResult(200,"ok",service.get4(ids));
    }

    @RequestMapping("/get5")
    public ResponseResult get5(@RequestParam Map<String ,Integer> map){
        System.out.println(map);
        List<Integer> ids = new ArrayList<>(map.values());
        return new ResponseResult(200,"ok",service.get5(ids));
    }
    @RequestMapping("/get6")
    public ResponseResult get6(@RequestParam Map<String ,Integer> map){
        System.out.println(map);
        List<Integer> ids = new ArrayList<>(map.values());
        return new ResponseResult(200,"ok",service.get6(ids));
    }
    @RequestMapping("/get7")
    public ResponseResult get7(@RequestParam Map<String ,Integer> map){
        System.out.println(map);
        List<Integer> ids = new ArrayList<>(map.values());
        return new ResponseResult(200,"ok",service.get7(ids));
    }
    @RequestMapping("/get8")
    public ResponseResult get8(@RequestParam Map<String ,Integer> map){
        System.out.println(map);
        List<Integer> ids = new ArrayList<>(map.values());
        return new ResponseResult(200,"ok",service.get8(ids));
    }
    @RequestMapping("/get9")
    public ResponseResult get9(@RequestParam Map<String ,Integer> map){
        System.out.println(map);
        List<Integer> ids = new ArrayList<>(map.values());
        return new ResponseResult(200,"ok",service.get9(ids));
    }

    @RequestMapping("/get10")
    public ResponseResult get10(@RequestParam Map<String ,Integer> map){
        System.out.println(map);
        List<Integer> ids = new ArrayList<>(map.values());
        return new ResponseResult(200,"ok",service.get10(ids));
    }
    @RequestMapping("/get11")
    public ResponseResult get11(@RequestParam Map<String ,Integer> map){
        System.out.println(map);
        List<Integer> ids = new ArrayList<>(map.values());
        return new ResponseResult(200,"ok",service.get11(ids));
    }
    @RequestMapping("/get12")
    public ResponseResult get12(@RequestParam Map<String ,Integer> map){
        System.out.println(map);
        List<Integer> ids = new ArrayList<>(map.values());
        return new ResponseResult(200,"ok",service.get12(ids));
    }

    @RequestMapping("/getallorgid")
    public ResponseResult getsection(){
        QueryWrapper queryWrapper =new QueryWrapper();
        queryWrapper.select("DISTINCT orgid");
        return new ResponseResult(200,"ok",service.list(queryWrapper));
    }

}
